package string;

public class StringBuilderDemo {
    public static void main(String[] args) {
        StringBuilder builder1 = new StringBuilder("123");

        String str1 = "abc";
        StringBuilder builder2 = new StringBuilder(str1);
        String str2 = builder2.toString();
        System.out.println(str2);

        builder1.append("123");
        System.out.println(builder1);
        builder1.replace(3,4,"abc");
        System.out.println(builder1);   //--------------没有下标越界异常
        builder1.insert(3,"5");
        System.out.println(builder1);
        builder1.delete(5,6);
        System.out.println(builder1);

//        StringBuilder builder = new StringBuilder("a");
//        for(int i=0;i<10;i++) {
//            builder.append(i);
//        }
//        System.out.println(builder);
    }



}
